import cv2
import numpy as np

# 读取图像
original_image = cv2.imread("D:/deepglobe/images/train/343016_sat.jpg", cv2.IMREAD_GRAYSCALE)



# 进行拉普拉斯变换
laplacian = cv2.Laplacian(original_image, cv2.CV_64F)

# 将结果转换为8位图像
laplacian = np.uint8(np.absolute(laplacian))


# 将原始图像乘以0.95
weighted_original = cv2.multiply(original_image, 0.95)

# 将拉普拉斯图乘以0.05
weighted_laplacian = cv2.multiply(laplacian, 0.05)

# 将两者相加得到新的图像
combined_image = cv2.add(weighted_original, weighted_laplacian)

# 下采样四倍
resized_image = cv2.resize(combined_image, (0, 0), fx=0.25, fy=0.25)

# 显示或保存组合后的图像
cv2.imshow('Combined Image', resized_image)
cv2.imwrite('combined_image.jpg', resized_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
